(()=>{
    // 存取器， 通过setter 和 geeter 访问对象属性

    class Person { 
        private firstName: string 
        private lastName: string 

        constructor(firstName: string, lastName : string) {
            this.firstName = firstName
            this.lastName = lastName
        }

        // 读取器 -- 负责读取数据
        get fullName() {
            return `${this.firstName}_${this.lastName}`
        }

        // 设置器 -- 负责设置数据的(修改)
        set fullName(val) {
            let names = val.split("_")
            this.firstName =  names[0]
            this.lastName = names[1]
        }

    }

    const person : Person = new Person('东方', '不败')
    console.log(person)
    console.log(person.fullName)
    console.log(person)
    person.fullName = '诸葛_孔明'
    console.log(person.fullName)

})()